//
//  RootTabBarViewController.m
//  MyYiJianKangApp
//
//  Created by 张国文 on 16/3/29.
//  Copyright © 2016年 hangzhouyijiyin. All rights reserved.
//

#import "RootTabBarViewController.h"
#import "HomePageViewController.h"
#import "ProductViewController.h"
#import "ZGWCommunityViewController.h"
#import "MineViewController.h"

@interface RootTabBarViewController ()

@end

@implementation RootTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self addSubViewController];
   
}

// 添加视图
- (void)addSubViewController
{
    [self addViewControllerClass:[HomePageViewController class] title:@"首页" imageName:@"shouyelan" selectImageName:@"shouyehuang"];
    [self addViewControllerClass:[ProductViewController class] title:@"产品" imageName:@"chanpinlan" selectImageName:@"chanpinhuang"];
    [self addViewControllerClass:[ZGWCommunityViewController class] title:@"社区" imageName:@"shequlan" selectImageName:@"shequhuang"];
    [self addViewControllerClass:[MineViewController class] title:@"我的" imageName:@"wodelan" selectImageName:@"wodehuang"];
}

// 封装一个方法
- (void)addViewControllerClass:(Class)class title:(NSString *)title imageName:(NSString *)imageName selectImageName:(NSString *)selectImageName
{
    UIViewController *viewC = [[class alloc]init];
    UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:viewC];
    navC.tabBarItem.title = title;
    navC.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    navC.tabBarItem.selectedImage = [[UIImage imageNamed:selectImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [self.tabBar setTintColor:[UIColor colorWithRed:209 / 255.0 green:124 / 255.0 blue:11 / 255.0 alpha:1]];
 
    //  viewC.navigationItem.title = title;
    // 被选中的颜色
    //   self.tabBar.selectedImageTintColor = [UIColor redColor];
    
    //   [self.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor], NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
    [self addChildViewController:navC];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
